define("zui/refresh",["zui/utils"],function(require,exports,module){

		var zUtil=require("zui/utils");

	  function zRefresh(options){

	  		 this.refreshWrapper=null;
	  		 this.refreshContainer="";
	  		 this.templateCls="";


	  		 this.pageSize=null;
	  		 this.start=0;
	  		 this.limit=null;
	  		 this.totalCount=null;
	  		 this.totalPageIndex=null;
	  		 this.data=[];


	  		 var _self=this;
	  		 if(!options.render) return;
	  		  _self.el=$(options.render);	

	  		 if(!options.container) return;
	  		 _self.refreshContainer=$(options.container);

	        $(options.render).refresh({
	            load: function (dir, type) {
			                var me = this;
			                _self.refreshWrapper=me;

			                if(zUtil.isFunction(options.ajaxfunc)){
			                	 	if(options.ajaxfunc(_self))
				                	    //数据加载完成后改变状态
				                        $(options.render).refresh("afterDataLoading",dir); 
				                     else{
				                     	 $(options.render).refresh("disable"); 
				                     }
			                }
			               
	               }
	        }); 
	        /*.on('statechange', function (e) {
					e.preventDefault();
					var data = e.args,
					$elem = data[1],
					state = data[2],
					dir = data[3];
					switch (state) {
					case 'loaded':
						$elem.html(dir == 'up' ? '点击刷新' : '上拉加载更多');
						break;
					case 'beforeload':
						$elem.html(dir == 'up' ? '松开立即刷新' : '松开立即加载');
						break;
					case 'loading':
						$elem.html(dir == 'up' ? '正在刷新中...' : '正在加载中...');
						break;
					case 'disable':
						$elem.html(dir == 'up' ? '对不起，没有更多内容了' : '没有更多内容');
						break;
					}
			})*/

	  }


	  zRefresh.prototype.clearData=function(){
	  		var _self=this;
	  		_self.refreshContainer.html("");
	  }

	 
	  zRefresh.prototype.getWrap=function(){
	  	  var _self=this;
	  	  return _self['refreshWrapper'];
	  }


	  return zRefresh;
});